﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InputManager : MonoBehaviour
{
    public static InputManager Ins;

    public event System.Action<KeyCode> KeyDownEvent;

    private void Awake()
    {
        Ins = this;
    }


    // Update is called once per frame
    void Update()
    {
        if (Input.anyKeyDown)
        {
            KeyDown();
        }
    }

    public void KeyDown()
    {
        KeyCode key = KeyCode.None;

        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            key = KeyCode.Alpha0;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            key = KeyCode.Alpha1;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            key = KeyCode.Alpha2;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            key = KeyCode.Alpha3;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            key = KeyCode.Alpha4;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            key = KeyCode.Alpha5;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            key = KeyCode.Alpha6;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            key = KeyCode.Alpha7;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            key = KeyCode.Alpha8;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            key = KeyCode.Alpha9;
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            key = KeyCode.Return;
        }


        if (key != KeyCode.None)
        {

            KeyDownEvent(key);
        }

    }


}
